<template>
	<view class="add">
		<view style="padding: 15px;">
			<view class="par-iphone" @tap="handleTap('picker3')">
				<view class="iphone-text">省市区</view>
				<input type="type" placeholder="点击按钮选择" v-model="addr" disabled/>
				<view class="add-but">选择地区</view>
			</view>
			<view class="par-iphone" @click="open()">
				<view class="iphone-text">所属街道</view>
				<input type="type" placeholder="点击获取" v-model="street" disabled/>
				<view class="add-but">选择街道</view>
			</view>

			<view class="par-but" @click="save">提交申请</view>
		</view>

		
		<!--省市区-->
		<lb-picker ref="picker3"
		  v-model="value3"
		  mode="multiSelector"
		  :list="list"
		  :level="3"
		  @confirm="handleConfirm">
		</lb-picker>


		<!--街道-->
		<uni-popup ref="recash2" type="bottom" style="z-index: 9999999999;">
			<view class="cash2">
				<view class="cash2-con">
					<view class="cash2-title" v-if="addr">当前城市：{{addr}}</view>
					<view class="cash2-tip" v-if="streetList.length >= 7">(温馨提示：下拉显示更多)</view>
					<scroll-view scroll-y show-scrollbar>
						<view class="cash2-list">
							<view class="list-item" v-for="(item,index) in streetList"  @click="confirmStreet(item)" :key="index">{{item.name}}</view>
						</view>
					</scroll-view>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import LbPicker from '@/components/lb-picker'
	import areaData from 'libs/area-data-min'
	export default {
		data() {
			return {
				reAddress: "", //回收地区
				value3: [],
				list: areaData,
				
				addr:'',
				street:'',
				streetId:'',
				streetList:[],
			}
		},
		onLoad(options) {
			
		},
		components: {
			LbPicker
		},
		methods: {
			getStreet(id){
				this.$http.getstreet({id:id}).then(res => {
					console.log(res)
					this.streetList = res.data
				})
			},
			//确认选择街道
			confirmStreet(item){
				this.street = item.name
				this.streetId = item.id
				this.$refs.recash2.close()
			},
			//省市区
			handleTap (picker) {
				this.$refs[picker].show()
			},
			handleConfirm (item) {
				console.log('confirm::', item)
				this.value3 = item.item
				this.addr = this.value3[0].label+this.value3[1].label+this.value3[2].label
				this.getStreet(this.value3[2].value)
			},
			//街道
			open() {
				if(!this.addr){
					uni.showToast({
						title:'请先选择省市区',
						icon:'none'
					})
					return
				}
				if(this.value3.length>0){
					this.getStreet(this.value3[2].value)
				}	
				this.$refs.recash2.open()
			},
			save(){
				if(!this.street){
					uni.showToast({
						title:'请选择街道',
						icon:'none'
					})
					return
				}
				
				let province = this.value3[0].value
				let city = this.value3[1].value
				let area = this.value3[2].value
				let formData = {
					province:province,
					city:city,
					area:area,
					street:this.streetId,
				}
				uni.showLoading({})
				this.$http.apply_riderstreet(formData).then(res => {
					uni.hideLoading()
					uni.showToast({
						title:res.msg,
						icon:'none'
					})
					if(res.code == 0){ 
						setTimeout(() => {
							uni.navigateBack({})
						},1000)
					}
				})
			},
		}
	}
</script>

<style scoped>
	.add {
		width: 100%;
	}

	.par-iphone:nth-of-type(1) {
		margin: 0;
	}

	.par-iphone {
		display: flex;
		flex-direction: row;
		background-color: rgba(187, 187, 187, 0.1);
		height: 43px;
		border-radius: 5px;
		align-items: center;
		margin: 15px 0;
		position: relative;
	}

	.iphone-text {
		color: #242424;
		font-size: 14px;
		padding: 0 12px;
		min-width: 116upx;
	}

	.uni-input-placeholder {
		font-size: 12px;
		color: #898989;
	}

	.add-but {
		border-radius: 15px;
		border: 1px solid #FE6103;
		color: #FE6103;
		padding: 3px 12px;
		font-weight: bold;
		position: absolute;
		right: 10px;
	}

	.par-but {
		width: 618upx;
		height: 80upx;
	
	background: linear-gradient(90deg, #FFC500 0%, #FF5F01 100%);
	box-shadow: 0px 4upx 8upx 0px #FFAB71;
		border-radius: 48upx;
		line-height: 80upx;
		text-align: center;
		font-size: 14px;
		color: #FFFFFF;
		margin: 30px auto;
	}

	.add-default {
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		margin: 20px 5px;
	}

	.add-del {
		color: #393D54;
		font-size: 16px;
		text-align: center;
		height: 48px;
		line-height: 48px;
		font-weight: bold;
		position: fixed;
		bottom: 0;
		background-color: #D3D4D9;
		width: 100%;
	}

	.add>>>.middle_view {
		border-radius: 0;
		width: 100vw;
	}

	.add>>>uni-button:after {
		display: none;
	}

	.add>>>uni-button {
		border-radius: 0;
		width: 100%;
	}

	.add>>>button {
		border-radius: 0;
		width: 100%;
	}

	.add>>>.flex_row {
		margin-top: 0 !important;
	}

	.add>>>.middle {
		/*  #ifdef  MP-WEIXIN  */
		top: 80%;
		/*  #endif  */

		/*  #ifdef  H5 */
		top: 82%;
		/*  #endif  */

	}

	/*街道*/
	.cash2 {
		height: 942upx;
		background: rgba(255, 255, 255, 1);
		border-radius: 25px 25px 0px 0;
	}

	.cash-but3 {
		display: flex;
		flex-direction: row;
		position: fixed;
		bottom: 0;
		justify-content: space-between;
		width: 100%;
	}

	.but-left3 {
		background-color: rgba(211, 212, 217, 1);
		width: 50%;
		height: 48px;
		text-align: center;
		font-size: 16px;
		color: rgba(57, 61, 84, 1);
		font-weight: bold;
		line-height: 48px;
	}

	.but-right3 {
		
		background: linear-gradient(90deg, #FFC500 0%, #FF5F01 100%);
		box-shadow: 0px 4upx 8upx 0px #FFAB71;
		width: 50%;
		height: 48px;
		text-align: center;
		font-size: 16px;
		color: #fff;
		font-weight: bold;
		line-height: 48px;
	}

	.cash2-title {
		font-weight: bold;
		font-size: 16px;
		text-align: center;
		padding: 25px 0 10px 0;
	}
	.cash2-tip{
		text-align: center;
		font-size: 12px;
		color: #FE4744;
		padding-bottom:20px;
	}

	.cash2-list {
		display: flex;
		flex-direction: column;
		height: 370px;
		margin-bottom:20px;
	}
	
	.list-item {
		color: #30344C;
		font-size: 14px;
		padding: 15px 0;
		border-bottom: 1px solid #D9D9DB;
		text-align: center;
	}

	.list-item:nth-of-type(1) {
		border-top: 1px solid #D9D9DB;
	}
</style>
